<!doctype html>
<html>

<head>
  <title>HyProto Live-Preview</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <script src="lib/JSONStorage.js"></script>
  <style>
  body,
  html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
  }
  
  #content {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0px;
  }
  </style>
</head>

<body>
  <iframe id="frame" width="100%" height="100%" frameborder="0"></iframe>
  <script>
  window.addEventListener('load', function(e) {
    var storage = new JSONStorage('https://glowing-fire-4998.firebaseio.com/hyproto');
    var frame = document.querySelector('#frame');

    if (window.location.hash.length > 1) {
      storage.retrieve(window.location.hash.substring(1), function onload(err, data) {
        if (!err && data) {
          var doc = frame.contentDocument;
          doc.open('text/html', '');
          doc.write(data);
          doc.close();
        }
      });
    }
  });
  </script>
</body>

</html>
